/**
 * 
 */
package org.crystal.jqweb.config;

import java.util.Map;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.crystal.jqweb.util.*;
/**
 * @author Crystal
 *
 */
public class JqWebProperties {
	private final Log log = LogFactory.getLog(getClass());
	private  String jqWebPropFileName="jqweb.properties";
	private Map jqWebProp;
	private static JqWebProperties jqprops=null;
	
	public static synchronized JqWebProperties getInstance() {
		if (jqprops == null) {
			jqprops = new JqWebProperties();
			jqprops.log.debug("getInstance()");
			jqprops.jqWebPropFileName=FileUtils.getWebRootFile("/WEB-INF/"+jqprops.jqWebPropFileName);
			PropsCofig propsCofig=new PropsCofig(jqprops.jqWebPropFileName);
			jqprops.jqWebProp=propsCofig.list();
		}
		return jqprops;
	}
	
	public  String getValue(String key) {
		try {
			log.debug("getValue() key:"+key);
			log.debug("getValue() key:"+key+",value:"+jqWebProp.get(key).toString());
			return jqWebProp.get(key).toString();
		} catch (Exception e) {
			log.debug("getValue() Exception!");
			//e.printStackTrace();
			return null;
		}
	}
}
